package com.example.demo.repository;

import com.example.demo.domain.CourseInfo;
import com.example.demo.domain.Student;
import jakarta.persistence.criteria.CriteriaBuilder;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;
import java.util.Map;


/**
 * 学生表的数据访问接口，后面的Integer表示id类型
 */
public interface StudentRepository extends JpaRepository<Student,Integer> {
    Student findBySid(String id);
    List<Student> findByStudentNameLike(String name);
    @Query(nativeQuery = true,value = "select s.sid sid,c.cid cid,c.cname course from tb_student s,tb_course c,(select * from tb_student_course where sid=?1) sc where sc.sid=s.sid and sc.cid=c.cid")
    List<Map<String,Object>> findCourseSelectionById(String id);
}
